// 7. 抽象类
// 常规类
abstract class Person {
    name:string
    age:number

    abstract speak():void
    constructor(name:string, age:number){
        this.name = name
        this.age = age
    }
}

// 继承：
class Student extends Person {
    constructor(name:string, age:number){
        super(name,age)
    }

    speak(): void {
        console.log('你好！我是学生:',this.name)
    }
}

// 继承：
class Teacher extends Person {
    // constructor(name:string, age:number){
    //     super(name,age)
    // }

    speak(): void {
        console.log('你好！我是⽼师:',this.name)
    }
}

// Student实例
const s12 = new Student('张同学',109)
const s22 = new Student('李同学',110)
console.log(s12)
console.log(s22)

// Teacher实例
const t1 = new Teacher('刘⽼师',104)
const t2 = new Teacher('孙⽼师',105)
console.log(t1)
console.log(t2)

// Person实例
// const p1 = new Person('周杰伦',38) // 由于Person是抽象类，所以此处不可以new Person的实例对象

// 抽象类：不能去实例化，但可以被别⼈继承，抽象类⾥有抽象⽅法
